package com.iqiyi.pps.epg.core.model.sginal;

import com.iqiyi.pps.epg.api.model.web.sginal.TServerStatus;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by zhang on 2017/8/23.
 */
@Entity
@Table(name = "server_status")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class ServerStatus {

    public static final int STATUS_IS_DELETE = -1;

    private long id;
    private int serverId;
    private String loadValue;
    private String disk;
    private String mem;
    private int inputStatus=-1;
    private int outputStatus=-1;
    private Timestamp addTime = new Timestamp(System.currentTimeMillis());


    private String freeSwapPer;
    private String dataFreePer;
    private String allFreePer;
    private String availableMemPer;
    private String inIcmploss;
    private String outIcmploss;

    private String dataFree;
    private String dataUsed;
    private String allFree;
    private String allUsed;
    private String allMem;
    private String availableMem;


    public static final String STATUS_LOAD = "system.cpu.load";
    public static final String STATUS_DISK = "vfs.fs.size";
    public static final String STATUS_MEM = "vm.memory.size";
    public static final String STATUS_SWAP = "system.swap.size";
    public static final String STATUS_ICMPLOSS = "icmppingloss";

    public TServerStatus convertThriftModel() {
        TServerStatus tServerStatus = new TServerStatus();
        tServerStatus.setId(this.id);
        tServerStatus.setServerId(this.serverId);
        tServerStatus.setLoad(this.loadValue);
        tServerStatus.setDisk(this.disk);
        tServerStatus.setMem(this.mem);
        tServerStatus.setInputStatus(this.inputStatus);
        tServerStatus.setOutputStatus(this.outputStatus);
        tServerStatus.setAddTime(this.addTime.toString());

        tServerStatus.setDataFreePer(this.dataFreePer+"");
        tServerStatus.setAllFreePer(this.allFreePer+"");
        tServerStatus.setAvailableMemPer(this.availableMemPer+"");
        tServerStatus.setFreeSwapPer(this.freeSwapPer+"");
        tServerStatus.setInIcmploss(this.inIcmploss+"");
        tServerStatus.setOutIcmploss(this.outIcmploss+"");
        return tServerStatus;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Column(name = "server_id")
    public int getServerId() {
        return serverId;
    }

    public void setServerId(int serverId) {
        this.serverId = serverId;
    }

    @Column(name = "load_value")
    public String getLoadValue() {
        return loadValue;
    }

    public void setLoadValue(String loadValue) {
        this.loadValue = loadValue;
    }

    @Column(name = "disk")
    public String getDisk() {
        return disk;
    }

    public void setDisk(String disk) {
        this.disk = disk;
    }

    @Column(name = "mem")
    public String getMem() {
        return mem;
    }

    public void setMem(String mem) {
        this.mem = mem;
    }

    @Column(name = "input_status")
    public int getInputStatus() {
        return inputStatus;
    }

    public void setInputStatus(int inputStatus) {
        this.inputStatus = inputStatus;
    }

    @Column(name = "output_status")
    public int getOutputStatus() {
        return outputStatus;
    }

    public void setOutputStatus(int outputStatus) {
        this.outputStatus = outputStatus;
    }

    @Column(name = "add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Column(name="in_icmploss")
    public String getInIcmploss() {
        return inIcmploss;
    }

    public void setInIcmploss(String inIcmploss) {
        this.inIcmploss = inIcmploss;
    }

    @Column(name="out_icmploss")
    public String getOutIcmploss() {
        return outIcmploss;
    }

    public void setOutIcmploss(String outIcmploss) {
        this.outIcmploss = outIcmploss;
    }

    @Column(name="free_swap_per")
    public String getFreeSwapPer() {
        return freeSwapPer;
    }

    public void setFreeSwapPer(String freeSwapPer) {
        this.freeSwapPer = freeSwapPer;
    }

    @Column(name="data_free_per")
    public String getDataFreePer() {
        return dataFreePer;
    }

    public void setDataFreePer(String dataFreePer) {
        this.dataFreePer = dataFreePer;
    }

    @Column(name="all_free_per")
    public String getAllFreePer() {
        return allFreePer;
    }

    public void setAllFreePer(String allFreePer) {
        this.allFreePer = allFreePer;
    }

    @Column(name="available_mem_per")
    public String getAvailableMemPer() {
        return availableMemPer;
    }

    public void setAvailableMemPer(String availableMemPer) {
        this.availableMemPer = availableMemPer;
    }

    @Transient
    public String getDataFree() {
        return dataFree;
    }

    public void setDataFree(String dataFree) {
        this.dataFree = dataFree;
    }

    @Transient
    public String getDataUsed() {
        return dataUsed;
    }

    public void setDataUsed(String dataUsed) {
        this.dataUsed = dataUsed;
    }

    @Transient
    public String getAllFree() {
        return allFree;
    }

    public void setAllFree(String allFree) {
        this.allFree = allFree;
    }

    @Transient
    public String getAllUsed() {
        return allUsed;
    }

    public void setAllUsed(String allUsed) {
        this.allUsed = allUsed;
    }

    @Transient
    public String getAllMem() {
        return allMem;
    }

    public void setAllMem(String allMem) {
        this.allMem = allMem;
    }

    @Transient
    public String getAvailableMem() {
        return availableMem;
    }

    public void setAvailableMem(String availableMem) {
        this.availableMem = availableMem;
    }
}

